// NOLINTBEGIN
#include <iostream>
using namespace std;

// 定义一个点类
class Point {
 public:
  // 构造函数，初始化点的坐标
  Point(float x = 0, float y = 0);
  // 设置点的坐标
  void setPoint(float, float);
  // 获取x坐标
  float getx() const {
    return x;
  }
  // 获取y坐标
  float getY() const {
    return y;
  }
  // 重载输出流操作符，输出点的信息
  friend ostream& operator<<(ostream&, Point const&);

 protected:
  float x, y;  // 点的坐标
};

// 点类构造函数实现
Point::Point(float a, float b) {
  x = a;
  y = b;
}

// 设置点的坐标实现
void Point::setPoint(float a, float b) {
  x = a;
  y = b;
}

// 重载输出流操作符实现
ostream& operator<<(ostream& output, Point const& p) {
  output << "[" << p.x << "," << p.y << "]" << endl;
  return output;
}

// 定义一个圆类，继承自点类
class Circle : public Point {
 public:
  // 构造函数，初始化圆的中心坐标和半径
  Circle(float x = 0, float y = 0, float r = 0);
  // 设置圆的半径
  void setRadius(float);
  // 获取圆的半径
  float getRadius() const;
  // 计算圆的面积
  float area() const;
  // 重载输出流操作符，输出圆的信息
  friend ostream& operator<<(ostream&, Circle const&);

 protected:
  float radius;  // 圆的半径
};

// 圆类构造函数实现
Circle::Circle(float a, float b, float r) : Point(a, b), radius(r) {}
// 设置圆的半径实现
void Circle::setRadius(float r) {
  radius = r;
}

// 获取圆的半径实现
float Circle::getRadius() const {
  return radius;
}

// 计算圆的面积实现
float Circle::area() const {
  return 3.14159 * radius * radius;
}

// 重载输出流操作符实现
ostream& operator<<(ostream& output, Circle const& c) {
  output << "Center=[" << c.x << "" << c.y << "].r=" << c.radius << ",area=" << c.area() << endl;
  return output;
}

// 定义一个圆柱体类，继承自圆类
class Cylinder : public Circle {
 public:
  // 构造函数，初始化圆柱体的中心坐标、半径和高度
  Cylinder(float x = 0, float y = 0, float r = 0, float h = 0);
  // 设置圆柱体的高度
  void setHeight(float);
  // 获取圆柱体的高度
  float getHeight() const;
  // 计算圆柱体的表面积
  float area() const;
  // 计算圆柱体的体积
  float volume() const;
  // 重载输出流操作符，输出圆柱体的信息
  friend ostream& operator<<(ostream&, Cylinder const&);

 protected:
  float height;  // 圆柱体的高度
};

// 圆柱体构造函数实现
Cylinder::Cylinder(float a, float b, float r, float h) : Circle(a, b, r), height(h) {}
// 设置圆柱体高度实现
void Cylinder::setHeight(float h) {
  height = h;
}

// 获取圆柱体高度实现
float Cylinder::getHeight() const {
  return height;
}

// 计算圆柱体表面积实现
float Cylinder::area() const {
  return 2 * Circle::area() + 2 * 3.14159 * radius * height;
}

// 计算圆柱体体积实现
float Cylinder::volume() const {
  return Circle::area() * height;
}

// 重载输出流操作符实现
ostream& operator<<(ostream& output, Cylinder const& cy) {
  output << "Center=[" << cy.x << "," << cy.y << "],r=" << cy.radius << ",h=" << cy.height << "narea=" << cy.area()
         << ",volume=" << cy.volume() << endl;
  return output;
}

int main() {
  Cylinder cy1(3.5, 6.4, 5.2, 10);
  // 输出圆柱体的原始信息
  cout << "original cylinder:nx=" << cy1.getx() << ",y=" << cy1.getY() << ",r=" << cy1.getRadius()
       << ",h=" << cy1.getHeight() << "narea=" << cy1.area() << ",volume=-" << cy1.volume() << endl;

  cy1.setHeight(15);
  cy1.setRadius(7.5);
  cy1.setPoint(5, 5);
  // 输出更新后的圆柱体信息
  cout << "nnew cylinder:n" << cy1;

  Point& pRef = cy1;  // 将圆柱体引用赋值给点引用
  cout << "npRef as a point:" << pRef;

  Circle& cRef = cy1;  // 将圆柱体引用赋值给圆引用
  cout << "ncRef as a Circle:" << cRef;

  //system("pause");
  return 0;
}

// NOLINTEND